<template>
	<view class="container">
		<view style="display: flex;justify-content: center;align-items: center;">
			<children-base-top-view :name="baby.name" :gender="baby.gender" :imgUrl="baby.imgUrl"
				:month="reportInfo.month" :height="reportInfo.physicalHeight" :weight="reportInfo.physicalWeight"
				:header="reportInfo.physicalHeader" />
		</view>
		<view v-for="report in reportArr" class="sec_secondary reportInfo">
			<h4>{{report.title}}</h4>
			<ul>
				<li v-for="item in report.list">
					<p v-if="reportInfo[item.value]">
						<span>{{item.label ? item.label : '--'}}</span>
						<span>{{reportInfo[item.value] ? reportInfo[item.value] : '--'}}</span>
					</p>
				</li>
			</ul>
		</view>
	</view>
</template>

<script>
	import {
		healthDetail
	} from '@/api/evaluate.js'
	import ChildrenBaseTopView from '@/components/children-base-top-view.vue'
	export default {
		components: {
			ChildrenBaseTopView
		},
		data() {
			return {
				reportInfo: {},
				reportArr: [{
					title: '一般情况',
					list: [{
						label: '面色',
						value: 'complexion'
					}, {
						label: '精神',
						value: 'spirit'
					}, {
						label: '反应（哭声）',
						value: 'reaction'
					}, {
						label: '体温',
						value: 'temperature'
					}, {
						label: '脉搏',
						value: 'pulse'
					}, {
						label: '呼吸',
						value: 'breathe'
					}]
				}, {
					title: '头面',
					list: [{
						label: '颅骨',
						value: 'skull'
					}, {
						label: '毛发',
						value: 'hair'
					}, {
						label: '眼睑',
						value: 'eyelid'
					}, {
						label: '结膜',
						value: 'conjunctiva'
					}, {
						label: '鼻',
						value: 'nose'
					}, {
						label: '口腔（粘膜，牙）',
						value: 'oralCavity'
					}]
				}, {
					title: '胸部',
					list: [{
						label: '外型',
						value: 'chestShape'
					}, {
						label: '心脏（心音，心律）',
						value: 'heart'
					}, {
						label: '肺部（呼吸音）',
						value: 'lung',
					}]
				}, {
					title: '腹部',
					list: [{
						label: '外型',
						value: 'abdomenShape'
					}, {
						label: '脐部',
						value: 'umbilicalRegion'
					}, {
						label: '肝脏',
						value: 'liver'
					}, {
						label: '脾脏',
						value: 'spleen'
					}, {
						label: '包块及压痛',
						value: 'masses'
					}]
				}, {
					title: '生殖器肛门',
					list: [{
						label: '外生殖器',
						value: 'genitals'
					}, {
						label: '肛门',
						value: 'anus'
					}]
				}, {
					title: '骨骼',
					list: [{
						label: '脊柱',
						value: 'spine'
					}, {
						label: '四肢',
						value: 'limbs'
					}]
				}, {
					title: '皮肤',
					list: [{
						label: '黄瘟',
						value: 'icterus'
					}, {
						label: '皮疹（红臀）',
						value: 'rash'
					}]
				}, {
					title: '神经系统',
					list: [{
						label: '拥抱反射',
						value: 'moroReflex'
					}, {
						label: '握持反射',
						value: 'graspReflex'
					}, {
						label: '爬行反射',
						value: 'crawlingReflex'
					}, {
						label: '踏步反射',
						value: 'steppingReflex'
					}, {
						label: '其他',
						value: 'nervousSystemOther'
					}]
				}, {
					title: '体格发育',
					list: [{
						label: '体重',
						value: 'physicalWeight',
						type: 1,
						lg: 8,
						validate: {
							rule: [{
								required: true,
								message: '请填写体重',
							}, ]
						},
						suffix: 'kg'
					}, {
						label: '身高',
						type: 1,
						lg: 8,
						value: 'physicalHeight',
						validate: {
							rule: [{
								required: true,
								message: '请填写身高',
							}, ]
						},
						suffix: 'cm'
					}, {
						label: '头围',
						value: 'physicalHeader',
						type: 1,
						lg: 8,
						validate: {
							rule: [{
								required: true,
								message: '请填写头围',
							}, ]
						},
						suffix: 'cm'
					}, {
						label: '胸围',
						value: 'physicalCircumference',
						type: 1,
						lg: 8,
						suffix: 'cm'
					}, {
						label: '前囟',
						value: 'physicalBregma',
						type: 1,
						lg: 8,
						suffix: 'cm'
					}]
				}, {
					title: '生长发育评价（百分位法）',
					list: [{
						label: '体重/月（年）龄',
						value: 'growEvaluateWeightScale'
					}, {
						label: '身长/月（年）龄',
						value: 'growEvaluateHeightScale'
					}]
				}, {
					title: '既往史',
					list: [{
						label: '疾病名称',
						value: 'previousHistorySick'
					}]
				}, {
					title: '家族史',
					list: [{
						label: '遗传性疾病（名称）',
						value: 'familyHistoryAllergicDisease'
					}, {
						label: '过敏性疾病（名称）',
						value: 'familyHistoryHereditaryDisease'
					}]
				}, {
					title: '喂养史',
					list: [{
						label: '乳类喂养方式',
						value: 'feedHistoryFeedingPatterns'
					}, {
						label: '乳类每天喂乳次数',
						value: 'feedHistoryFeedingTimes'
					}, {
						label: '乳类每次喂乳量',
						value: 'feedHistoryFeedingQuantity'
					}, {
						label: '辅食起始时间',
						value: 'feedHistoryComplementaryBetween'
					}, {
						label: '辅食种类名称',
						value: 'feedHistoryComplementaryCategory'
					}, {
						label: '辅食量',
						value: 'feedHistoryComplementaryQuantity'
					}, {
						label: '辅食食物过敏',
						value: 'feedHistoryComplementaryHereditary'
					}]
				}, {
					title: '作息习惯',
					list: [{
						label: '睡眠起床时间',
						value: 'routineWakeUpTime'
					}, {
						label: '睡眠入睡时间',
						value: 'routineSleepInertia'
					}, {
						label: '白天睡眠时间',
						value: 'routineSleepTime'
					}, {
						label: '沐浴频率',
						value: 'routineBathFrequency'
					}, {
						label: '沐浴时间',
						value: 'routineBathTime'
					}, {
						label: '二便频率',
						value: 'routineDefecationFrequency'
					}, {
						label: '二便性状',
						value: 'routineDefecationCharacter'
					}, {
						label: '外出频率',
						value: 'routineOutFrequency'
					}, {
						label: '外出时间',
						value: 'routineOutTime'
					}]
				}, {
					title: '父母关注的问题',
					list: [{
						label: '问题一',
						value: 'parentsAttentionQuestion1'
					}, {
						label: '问题二',
						value: 'parentsAttentionQuestion2'
					}]
				}, {
					title: '保健指导',
					list: [{
						label: '指导一',
						value: 'healthGuide1'
					}, {
						label: '指导二',
						value: 'healthGuide2'
					}, {
						label: '指导三',
						value: 'healthGuide3'
					}, {
						label: '指导四',
						value: 'healthGuide4'
					}]
				}],

				baby: {},
			}
		},
		onLoad(options) {
			console.log(options);
			this.evaluateRecordId = options.evaluateRecordId;
			this.getHealthDetail();
		},
		methods: {
			getHealthDetail() {
				uni.showLoading({});
				let that = this;
				healthDetail(this.evaluateRecordId).then(res => {
					console.log(res);
					uni.hideLoading();
					let reportList = [];
					let healthBaseInfo = res.data.healthBaseInfo;
					that.baby = res.data.children;
					that.reportInfo = healthBaseInfo;
					for (let i = 0; i < that.reportArr.length; i++) {
						let valid_len = 0;
						let array = that.reportArr[i];
						for (let j = 0; j < array.list.length; j++) {
							let item = array.list[j];
							if (healthBaseInfo[item.value]) {
								valid_len++
							}
						}
						console.log(valid_len)
						if (valid_len > 0) {
							reportList.push(array)
						}
					}
					that.reportArr = reportList;
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: $app-page-bg-color;
	}

	.container {
		display: flex;
		flex-direction: column;
		padding-left: 30rpx;
		padding-right: 30rpx;
	}

	.sec_secondary {
		margin: 30rpx 20rpx;
	}

	.sec_secondary h2 {
		position: relative;
		font-size: 30rpx;
		padding-left: 16rpx;
		font-weight: normal;
		margin-bottom: 18rpx;
		line-height: 1;
		color: #50576a;
		font-family: 'PingFangSC-Bold'
	}

	.sec_secondary h2 span {
		float: right;
		font-size: 30rpx;
		color: #808aa7
	}

	.sec_secondary h2::before {
		content: '';
		display: block;
		position: absolute;
		left: 0;
		width: 7rpx;
		background: #cecdf8;
		top: 0;
		bottom: 0;
		border-radius: 4rpx;
	}

	.reportInfo {
		p {
			display: flex;
			flex-direction: row;
			align-items: center;
			justify-content: space-between;
			line-height: 2.4;
			margin-top: 8rpx;
			border-bottom: 1rpx solid #e5e5e5;

			span {
				max-width: 50%;
				font-size: 26rpx;
				color: #666;

				&:nth-child(2) {
					line-height: 1.5;
					font-size: 26rpx
				}
			}
		}

		h4 {
			font-size: 30rpx;
			font-weight: normal
		}
	}
</style>
